<template>
    <el-dialog :visible.sync="dialogVisible" title="编辑测点">
      <el-form :model="form">
        <el-form-item label="测点名称">
          <el-input v-model="form.name"></el-input>
        </el-form-item>
        <el-form-item label="测点描述">
          <el-input v-model="form.description"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取消</el-button>
        <el-button type="primary" @click="saveEdit">保存</el-button>
      </div>
    </el-dialog>
  </template>
  
  <script>
  export default {
    props: {
      form: {
        type: Object,
        required: true
      }
    },
    data() {
      return {
        dialogVisible: false
      };
    },
    methods: {
      saveEdit() {
        // 触发保存事件，并传递表单数据
        this.$emit('save');
        this.dialogVisible = false;
      }
    }
  };

  const editForm = reactive({
  id: '',
  name: '',
  description: ''
});

const editItem = (row) => {
  editForm.id = row.id;
  editForm.name = row.name;
  editForm.description = row.description;
  if (editPointDialog.value) {
    editPointDialog.value.dialogVisible = true;
  }
}

const saveEdit = async () => {
  try {
    const res = await miApi.updateMeasureInfo(editForm);
    if (res.data.status) {
      ElMessage.success("测点更新成功");
      getMeasureInfoData();
    } else {
      ElMessage.error("测点更新失败");
    }
  } catch (error) {
    ElMessage.error("测点更新失败");
  }
}

  </script>
  